#!/usr/bin/env python
"""
Nagios plugin that monitors GridFtp service on a NorduGrid ARC CE
"""

__author__ = "Placi Flury grid@switch.ch"
__copyright__  = "Copyright 2010, SMSCG an AAA/SWITCH project"
__date__ = "12.11.2008"
__version__ = "0.1.0"

import sys
from nagios_plugin import NagiosPluginBasic, LocalService


class GridFtp(NagiosPluginBasic):
    """
    Checks whether GridFtp service is running. It's a local check
    without any connectivity testing.
    """
    def __init__(self):
        parser = NagiosPluginBasic.getOptions(self)
        parser.remove_option("-c")   # removing thresholds
        parser.remove_option("-w")
        parser.remove_option("-H")   # remove hostname option
        parser.parse_args()


    def main(self):

        service = LocalService("gridftpd")
        msg, return_code = service.getstate()

        print msg
        sys.exit(return_code)


if __name__ =="__main__":
    g = GridFtp()
    g.main()
